<template>
  <van-cell class="article-item-container">
    <template #title>
        <!-- 使用vant中提高的内置样式来啊实现两行文本的省 -->
      <div class="title van-multi-ellipsis--12">{{ article.title }}</div>
    </template>

    <!-- 底部信息 -->
    <template #label>
      <!-- 根据图片数量进行判断 -->
      <div v-if="article.cover.type === 3" class="cover-wrap">
        <div v-for="(img, index) in article.cover.images" :key="index" class="cover-item">
          <van-image class="cover-image" fit="cover" :src="img" />
        </div>
      </div>

      <!-- 底部作者信息 -->
      <div class="label-info-wrap">
        <span>{{ article.aut_name }}</span>
        <span>{{ article.comm_count }}</span>
        <span>{{ article.pubdate | relativeTime }}</span>
      </div>
    </template>

    <!-- 右侧图片信息 -->
    <template #default v-if="article.cover.type === 1">
        <van-image class="right-image" fit="cover" :src="article.cover.images[0]" />
    </template>
  </van-cell>
</template>

<script>
export default {
  name: 'ArticleItem',
  props: {
    article: {
      type: Object,
      default: () => ({})
    }
  },
  data () {
    return {

    }
  },
  methods: {

  }
}
</script>

<style lang="less" scoped>
    .article-item-container {
        .title {
            color: #3a3a3a;
            font-size: 32px;
        }
    }

    .van-cell__value {
        width: 230px;
        height: 146px;
        //取消右侧盒子的flex不就，这样让横向的剩余部分都留给标题
        flex: unset;
        padding-left: 25px;
        .right-image {
            width: 100%;
            height: 100%;
        }
    }

    .label-info-wrap {
        span {
            font-size: 22px;
            color: #b4b4b4;
            margin-right: 25px;
        }
    }

    .cover-wrap {
        display: flex;
        padding: 30px 0;

        .cover-item {
            flex: 1;
            height: 146px;

            &:not(:last-child) {
                padding-right: 10px;
            }

            .cover-image {
                width: 100%;
                height: 100%;
            }
        }
    }
</style>
